﻿using Sunny.UI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace MesBSW.View.Dialog.Mes
{
    public partial class ExcelSheetChooseDia : UIEditForm
    {
        private List<string> sheet_list = new List<string>();
        private List<string> _choose_list = new List<string>();

        public List<string> ChooseList 
        { 
            get { return _choose_list; } 
        }

        public ExcelSheetChooseDia(List<string> sheetList)
        {
            InitializeComponent();
            this.sheet_list = sheetList;
            this.InitListView(this.sheet_list);
        }

        private void InitListView(List<string> sheetList)
        {
            this.livExcelSheet.Items.Clear();
            if (sheetList != null && sheetList.Count > 0)
            {
                foreach (string sheet in sheetList)
                {
                    ListViewItem tmpItem = new ListViewItem(sheet);
                    tmpItem.Checked = false;
                    if (!this.livExcelSheet.Items.Contains(tmpItem))
                    {
                        this.livExcelSheet.Items.Add(tmpItem);
                    }
                }
            }
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            foreach (ListViewItem item in this.livExcelSheet.Items)
            {
                if (item.Checked)
                {
                    this._choose_list.Add(item.Text);
                }
            }
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this._choose_list = new List<string>();
        }
    }
}
